/*
 * @Description: 标签模型
 * @Author: zheng yiliang
 * @Date: 2021-04-13 20:58:34
 * @LastEditTime: 2021-04-18 14:24:40
 * @LastEditors: zheng yiliang
 */


const mongoose = require('../core/mongodb')
const { Schema, model } = mongoose
const autoIncrement = require('mongoose-auto-increment-fix');

// 标签模型
const tagSchema = new Schema({
  // 标签名称
  name: { type: String, required: true, validate: /\S+/ },

  // 标签描述
  desc: String,

  // 图标
  icon: String,

  // 发布日期
  create_time: { type: Date, default: Date.now },

  // 最后修改日期
  update_time: { type: Date, default: Date.now },
});
// 自增ID插件配置
tagSchema.plugin(autoIncrement.plugin, {
  model: 'Tag',
  field: 'id',
  startAt: 1,
  incrementBy: 1
});
// 标签模型
module.exports = model('Tag', tagSchema);
